%define _python_bytecompile_build 0

Summary(ru_RU.UTF-8): Начальные настройки пользователя операционной системы М
Summary:	M OS default desktop settings
Name:		mos-std
Version:	5.8
Release:	1
License:	GPLv3
Group:		System/Configuration/Other
Url:		https://os.mos.ru

# c=0 ; for i in $(ls -1v | grep -v '\.spec'); do echo -e "Source$((10+c)):\t$i" ; c=$((c+1)); done | xclip
Source10:	DolphinGlobalViewProperties
Source11:	Home.desktop
Source12:	OpenBoardUser.config
Source13:	baloofilerc
Source14:	chromium.json
Source16:	libreoffice.xcu
Source17:	powermanagementprofilesrcd
Source18:	powermanagementprofilesrcp
Source19:	trash.desktop
Source21:	mos-std-generic-trigger.py
Source22:	mos-std-panel-desktopcontainment-trigger.py
Source23:	kscreenlockerrcd
Source24:	kscreenlockerrcp
Source25:	kded5rc
Source26:	kded_device_automounterrc
Source27:	open_dolphin_on_usb.py
Source28:	open_dolphin_on_usb.desktop
Source29:	onboard-conf-trigger.py
Source30:	mos-std-panel-layoutjs-trigger.py
Source31:	kxkbrcp
Source32:	10-chromium-default-incognito.sh
# Разметка диска для Анаконды, сейчас пока одинаковая и для десктопа, и для панелей
Source34:	10-mos-disk.conf
Source35:	plasmanotifyrc
Source36:	kwinrcd
Source37:	kwinrcp
Source39:	uchebnik.desktop
Source40:	kdewallet.kwl
Source41:	kdewallet.salt
Source43:	kglobalshortcutsrc
Source44:	sysusers.conf
Source45:	10-mos-network.conf
Source46:	75-mos-sddm.conf
Source47:	ru.mos.cupspkhelper.mechanism.rules
Source48:	ru.mos.NetworkManager.rules

BuildArch:	noarch

%description
Standart files on M OS desktops.

%description -l ru_RU.UTF-8
Файлы по умолчанию для Рабочего стола М ОС, настройка приложений и настройка иконок.

#-----------------------------------------------------------------------------------

%package desktop
Conflicts:	%{name}-panel
Summary(ru_RU.UTF-8): Начальные настройки пользователя М ОС для АРМ
Summary: M OS default desktop settings
RemovePathPostfixes: .fordesktop
Requires:	grep
Requires:	sed
Requires(post):	coreutils
Requires(post):	/bin/systemd-sysusers
Requires:	(anaconda-%{name} if anaconda-core)

%description desktop
Standart files on M OS desktops.

%description -l ru_RU.UTF-8 desktop
Файлы по умолчанию для Рабочего стола М ОС,
настройка приложений и настройка иконок для рабочих мест (ноутбков, моноблоков и т.п.)

%files desktop
%dir %{_libdir}/qt5/qml/org/mos
/etc/skel/.config/kwinrc.fordesktop
/etc/skel/.config/baloofilerc
# will be renamed to powermanagementprofilesrc when installing
/etc/skel/.config/powermanagementprofilesrc.fordesktop
/etc/skel/.config/kscreenlockerrc.fordesktop
"/etc/skel/.config/chromium/Default/Preferences"
"/etc/skel/.config/libreoffice/4/user/registrymodifications.xcu"
"/etc/skel/.local/share/OpenBoard/OpenBoardUser.config"
"/etc/skel/.local/share/dolphin/view_properties/global/.directory"
"/etc/skel/.local/share/kwalletd/kdewallet.kwl"
"/etc/skel/.local/share/kwalletd/kdewallet.salt"
"/etc/skel/Рабочий стол/Home.desktop"
"/etc/skel/Рабочий стол/trash.desktop"
%{_libexecdir}/mos-std-generic-trigger.py
%{_sysusersdir}/mos-std.conf
%{_sysconfdir}/sddm.conf.d/75-mos-sddm.conf
%{_datadir}/polkit-1/rules.d/ru.mos.cupspkhelper.mechanism.rules
%{_datadir}/polkit-1/rules.d/ru.mos.NetworkManager.rules

%ghost "/etc/skel/Рабочий стол/chromium-browser.desktop"
%ghost "/etc/skel/Рабочий стол/mos-appstore.desktop"

%post desktop
%sysusers_create mos-std.conf
# If done in %%install, symlinks are converted to real contents of files
# http://lists.rpm.org/pipermail/rpm-list/2014-October/001646.html
ln -sf %{_datadir}/applications/chromium-browser.desktop "/etc/skel/Рабочий стол"/chromium-browser.desktop
ln -sf %{_datadir}/applications/mos-appstore.desktop "/etc/skel/Рабочий стол"/mos-appstore.desktop

%transfiletriggerin desktop -- %{_libdir}
if ! grep -q "^%{_libdir}/libKF5XmlGui.so.5$"; then exit 0; fi
sed --follow-symlinks -i %{_libdir}/libKF5XmlGui.so.5 -e 's,https://www.kde.org/donate?app=,https://os.mos.ru/r/blago?appl=,g'

%transfiletriggerin desktop -- /usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/config
if ! grep -q "^/usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/config/main.xml$"; then exit 0; fi
python3 %{_libexecdir}/mos-std-generic-trigger.py

%transfiletriggerin desktop -- /etc/xdg
# https://bugzilla.rosalinux.ru/show_bug.cgi?id=13238
if ! grep -q "^/etc/xdg/powermanagementprofilesrc$"; then exit 0; fi
echo '' > /etc/xdg/powermanagementprofilesrc

#-----------------------------------------------------------------------------------

%package panel
Conflicts:	%{name}-desktop
Summary(ru_RU.UTF-8): Начальные настройки пользователя М ОС для интерактивных панелей
Summary: M OS default desktop settings for interactive panels
RemovePathPostfixes: .forpanel
Requires:	grep
Requires:	sed
Requires:	python3-udev
Requires(post):	coreutils
Requires(post):	/bin/systemd-sysusers
Requires:	(anaconda-%{name} if anaconda-core)

%description panel
Standart files on M OS panels

%description -l ru_RU.UTF-8 panel
Файлы по умолчанию для Рабочего стола М ОС, настройка приложений и настройка иконок для интерактивных панелей

%files panel
%dir %{_libdir}/qt5/qml/org/mos
/etc/xdg/mos/autostart/open_dolphin_on_usb.desktop
%{_libexecdir}/open_dolphin_on_usb
/etc/skel/.config/kglobalshortcutsrc
/etc/skel/.config/plasmanotifyrc
/etc/skel/.config/kwinrc.forpanel
/etc/skel/.config/baloofilerc
/etc/skel/.config/kded5rc
/etc/skel/.config/kded_device_automounterrc
# will be renamed to powermanagementprofilesrc when installing
/etc/skel/.config/powermanagementprofilesrc.forpanel
/etc/skel/.config/kscreenlockerrc.forpanel
# Is put over /etc/xdg/mos/kxkbrc from mos-xdg adding switching keyboard
# layout by right Alt (grp:toggle) for working with filetrigger for onboard
/etc/skel/.config/kxkbrc.forpanel
"/etc/skel/.config/chromium/Default/Preferences"
"/etc/skel/.config/libreoffice/4/user/registrymodifications.xcu"
"/etc/skel/.local/share/OpenBoard/OpenBoardUser.config"
"/etc/skel/.local/share/dolphin/view_properties/global/.directory"
"/etc/skel/.local/share/kwalletd/kdewallet.kwl"
"/etc/skel/.local/share/kwalletd/kdewallet.salt"
"/etc/skel/Рабочий стол/Home.desktop"
"/etc/skel/Рабочий стол/trash.desktop"
"/etc/skel/Рабочий стол/uchebnik.desktop"
%{_libexecdir}/mos-std-generic-trigger.py
%{_libexecdir}/mos-std-panel-desktopcontainment-trigger.py
%{_libexecdir}/mos-std-panel-layoutjs-trigger.py
%{_libexecdir}/onboard-conf-trigger.py
%{_sysusersdir}/mos-std.conf
%{_sysconfdir}/sddm.conf.d/75-mos-sddm.conf
%{_datadir}/polkit-1/rules.d/ru.mos.cupspkhelper.mechanism.rules
%{_datadir}/polkit-1/rules.d/ru.mos.NetworkManager.rules

%config %{_sysconfdir}/profile.d/10-chromium-default-incognito.sh
%ghost "/etc/skel/Рабочий стол/chromium-browser.desktop"
%ghost "/etc/skel/Рабочий стол/OpenBoard.desktop"
%ghost "/etc/skel/Рабочий стол/onboard.desktop"

%post panel
%sysusers_create mos-std.conf
# If done in %%install, symlinks are converted to real contents of files
# http://lists.rpm.org/pipermail/rpm-list/2014-October/001646.html
ln -sf %{_datadir}/applications/OpenBoard.desktop "/etc/skel/Рабочий стол"/OpenBoard.desktop
ln -sf %{_datadir}/applications/onboard.desktop "/etc/skel/Рабочий стол"/onboard.desktop
ln -sf %{_datadir}/applications/chromium-browser.desktop "/etc/skel/Рабочий стол"/chromium-browser.desktop

%transfiletriggerin panel -- %{_libdir}
if ! grep -q "^%{_libdir}/libKF5XmlGui.so.5$"; then exit 0; fi
sed --follow-symlinks -i %{_libdir}/libKF5XmlGui.so.5 -e 's,https://www.kde.org/donate?app=,https://os.mos.ru/r/blago?appl=,g'

%transfiletriggerin panel -- /usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/config
if ! grep -q "^/usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/config/main.xml$"; then exit 0; fi
%{_libexecdir}/mos-std-generic-trigger.py
%{_libexecdir}/mos-std-panel-desktopcontainment-trigger.py

%transfiletriggerin panel -- /usr/share/plasma/layout-templates/org.kde.plasma.desktop.defaultPanel/contents
if ! grep -q "^/usr/share/plasma/layout-templates/org.kde.plasma.desktop.defaultPanel/contents/layout.js$"; then exit 0; fi
%{_libexecdir}/mos-std-panel-layoutjs-trigger.py

%transfiletriggerin panel -- /etc/xdg
# https://bugzilla.rosalinux.ru/show_bug.cgi?id=13238
if ! grep -q "^/etc/xdg/powermanagementprofilesrc$"; then exit 0; fi
echo '' > /etc/xdg/powermanagementprofilesrc

%transfiletriggerin panel -- /etc/onboard
if ! grep -q "^/etc/onboard/onboard-defaults.conf$"; then exit 0; fi
%{_libexecdir}/onboard-conf-trigger.py

#------------------------------------------------------------------

%package -n anaconda-%{name}
Summary(ru_RU.UTF-8): Конфигурация Anaconda для М ОС
Summary:	Anaconda installer configs for M OS
Requires:	anaconda-core

%description -n anaconda-%{name}
Anaconda installer configs for M OS

%description -l ru_RU.UTF-8 -n anaconda-%{name}
Настройка схемы автоматической разбивки диска на BTRFS:
- Включение создания swap при разбивке;
- Минимальный размер корня 20ГБ.
Настройка сетевых подключений.

%files -n anaconda-%{name}
/etc/anaconda/conf.d/10-mos-disk.conf
/etc/anaconda/conf.d/10-mos-network.conf

#------------------------------------------------------------------

%prep
%setup -T -c
cp %sources .

%install

mkdir -p %{buildroot}/etc/xdg/mos/autostart
mkdir -p %{buildroot}/etc/skel/.config
mkdir -p %{buildroot}/etc/skel/.config/chromium/Default
mkdir -p %{buildroot}/etc/skel/.config/libreoffice/4/user
mkdir -p %{buildroot}/etc/skel/.local/share/OpenBoard
mkdir -p %{buildroot}/etc/skel/.local/share/kwalletd
mkdir -p %{buildroot}/etc/skel/.local/share/dolphin/view_properties/global
mkdir -p %{buildroot}"/etc/skel/Рабочий стол"
mkdir -p %{buildroot}%{_libexecdir}
mkdir -p %{buildroot}%{_datadir}/mos/std-conf
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
mkdir -p %{buildroot}%{_sysconfdir}/sddm.conf.d
mkdir -p %{buildroot}/etc/anaconda/conf.d
mkdir -p %{buildroot}%{_libdir}/qt5/qml/org/mos
mkdir -p %{buildroot}%{_sysusersdir}
mkdir -p %{buildroot}%{_datadir}/polkit-1/rules.d

install -pm600 kdewallet.kwl %{buildroot}/etc/skel/.local/share/kwalletd/
install -pm600 kdewallet.salt %{buildroot}/etc/skel/.local/share/kwalletd/
install -pm644 powermanagementprofilesrcd %{buildroot}/etc/skel/.config/powermanagementprofilesrc.fordesktop
install -pm644 powermanagementprofilesrcp %{buildroot}/etc/skel/.config/powermanagementprofilesrc.forpanel
install -pm644 kwinrcd %{buildroot}/etc/skel/.config/kwinrc.fordesktop
install -pm644 kwinrcp %{buildroot}/etc/skel/.config/kwinrc.forpanel
install -pm644 baloofilerc %{buildroot}/etc/skel/.config
install -pm644 kded5rc %{buildroot}/etc/skel/.config
install -pm644 kded_device_automounterrc %{buildroot}/etc/skel/.config
install -pm644 kglobalshortcutsrc %{buildroot}/etc/skel/.config
install -pm644 kscreenlockerrcd %{buildroot}/etc/skel/.config/kscreenlockerrc.fordesktop
install -pm644 kscreenlockerrcp %{buildroot}/etc/skel/.config/kscreenlockerrc.forpanel
install -pm644 kxkbrcp %{buildroot}/etc/skel/.config/kxkbrc.forpanel
install -pm644 chromium.json %{buildroot}/etc/skel/.config/chromium/Default/Preferences
install -pm644 libreoffice.xcu %{buildroot}/etc/skel/.config/libreoffice/4/user/registrymodifications.xcu
install -pm644 OpenBoardUser.config %{buildroot}/etc/skel/.local/share/OpenBoard
install -pm600 DolphinGlobalViewProperties %{buildroot}/etc/skel/.local/share/dolphin/view_properties/global/.directory
install -pm644 Home.desktop %{buildroot}"/etc/skel/Рабочий стол"
install -pm644 trash.desktop %{buildroot}"/etc/skel/Рабочий стол"
install -pm644 uchebnik.desktop %{buildroot}"/etc/skel/Рабочий стол"
install -pm755 mos-std-generic-trigger.py %{buildroot}%{_libexecdir}
install -pm755 mos-std-panel-desktopcontainment-trigger.py %{buildroot}%{_libexecdir}
install -pm755 mos-std-panel-layoutjs-trigger.py %{buildroot}%{_libexecdir}
install -pm755 onboard-conf-trigger.py %{buildroot}%{_libexecdir}
install -pm755 open_dolphin_on_usb.py %{buildroot}%{_libexecdir}/open_dolphin_on_usb
install -pm644 open_dolphin_on_usb.desktop %{buildroot}/etc/xdg/mos/autostart/
install -pm755 10-chromium-default-incognito.sh %{buildroot}%{_sysconfdir}/profile.d
install -pm644 10-mos-disk.conf %{buildroot}/etc/anaconda/conf.d/
install -pm644 10-mos-network.conf %{buildroot}/etc/anaconda/conf.d/
install -pm644 plasmanotifyrc %{buildroot}/etc/skel/.config
install -pm644 sysusers.conf %{buildroot}%{_sysusersdir}/mos-std.conf
install -pm644 75-mos-sddm.conf %{buildroot}%{_sysconfdir}/sddm.conf.d
install -pm644 ru.mos.cupspkhelper.mechanism.rules %{buildroot}%{_datadir}/polkit-1/rules.d
install -pm644 ru.mos.NetworkManager.rules %{buildroot}%{_datadir}/polkit-1/rules.d
